home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / HYP / E-G / Externals.cpt / Externals / card_6661.txt < prev    next >
Text File  |  1989-02-26  |  2KB  |  56 lines

  1. -- card: 6661 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 2795
  5. -- name: RenameFile
  6.  
  7.  
  8. -- part contents for background part 1
  9. ----- text -----
  10. XFCN
  11.  
  12. -- part contents for background part 22
  13. ----- text -----
  14. RenameFile("OldName","NewName")
  15.  
  16. -- part contents for background part 13
  17. ----- text -----
  18. ‚Ä¢  RenameFile("OldName","NewName"). This renames a file, keeping it in the same folder (or at the root of the volume). "OldName" is a full pathname, and "NewName" is a replacement for the last component of that path. For instance: put RenameFile("HD:Telecom:capture","session") into err will produce a file called "HD:Telecom:session" if it succeeds. 
  19.  
  20. 0 is returned on success, a negative number for an Operating System error, and 1 for a parameter error. See the OsErr handler in the stack script for a suggestion on how to handle this.
  21.  
  22. -- OsErr: for displaying Operating system error codes returned by
  23. -- Sublaunch, RenameFile, MoveFile and DeleteFile XFCNs.
  24.  
  25. on OsErr err
  26.   -- Translate the most common ones
  27.   if err > 0 then -- XFCN convention
  28.     put "Parameter error with function" into errstr
  29.   else if err is -59 then
  30.     put "Problem during rename" into errstr
  31.   else if err is -54 then
  32.     put "Attempt to open locked file for writing" into errstr
  33.   else if err is -46 then
  34.     put "Volume locked by software" into errstr
  35.   else if err is -45 then
  36.     put "File locked" into errstr
  37.   else if err is -44 then
  38.     put "Volume locked by hardware" into errstr
  39.   else if err is -43 then
  40.     put "File not found" into errstr
  41.   else if err is -37 then
  42.     put "Bad volume or file name" into errstr
  43.   else if err is -36 then
  44.     put "I/O error" into errstr
  45.   else if err is -35 then
  46.     put "No such volume" into errstr
  47.   else if err is -34 then
  48.     put "Disk is full" into errstr
  49.   else if err is -49 then
  50.     put "File already open for writing" into errstr
  51.   else
  52.     put "Failed with error" && err into errstr
  53.   end if
  54.   answer errstr with "OK"
  55. end OsErr
  56.